var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(t, e) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(t, e) {
        t.__proto__ = e;
    } || function(t, e) {
        for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
    })(t, e);
}, function(t, e) {
    function a() {
        this.constructor = t;
    }
    o(t, e), t.prototype = null === e ? Object.create(e) : (a.prototype = e.prototype, 
    new a());
}), a = this && this.__decorate || function(t, e, o, a) {
    var n, i = arguments.length, r = i < 3 ? e : null === a ? a = Object.getOwnPropertyDescriptor(e, o) : a;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, a); else for (var c = t.length - 1; 0 <= c; c--) (n = t[c]) && (r = (i < 3 ? n(r) : 3 < i ? n(e, o, r) : n(e, o)) || r);
    return 3 < i && r && Object.defineProperty(e, o, r), r;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("LoadManager"), s = e("WebManager"), c = cc._decorator, l = c.ccclass, d = c.property, u = function(e) {
    function t() {
        var t = null !== e && e.apply(this, arguments) || this;
        return t.buttons = [], t.type = 0, t.data = [], t.btnClose = null, t.width = 0, 
        t;
    }
    return i(t, e), t.prototype.onEnable = function() {
        this.data = [];
        for (var t = 0; t < 6; t++) this.data.push({
            appid: "",
            name: "",
            is_open_code: !1,
            path: "",
            icon: "",
            qr_code: ""
        });
        for (t = 0; t < 6; t++) this.loaddata(t);
    }, t.prototype.setType = function(t) {
        this.type = t;
    }, t.prototype.loaddata = function(e) {
        var o = this;
        s.default.getInstance().redirect({
            Type: this.type + e,
            CurrentAppid: this.data[e].appid,
            CurrentPath: this.data[e].path,
            success: function(t) {
                o && o.node && 0 == t.data.code && t.data.data && (o.data[e] = t.data.data, o.loadsprite(o.data[e], e));
            }
        });
    }, t.prototype.loadsprite = function(t, e) {
        var o = this;
        t.icon && r.default.getInstance().load({
            url: t.icon,
            success: function(t) {
                try {
                    t instanceof cc.Texture2D ? (o.buttons[e].normalSprite = new cc.SpriteFrame(t), 
                    o.buttons[e].node.width = o.width, o.buttons[e].node.height = o.width) : cc.log(t);
                } catch (t) {}
            },
            fail: function(t) {
                cc.error(t);
            }
        });
    }, t.prototype.onClickGame = function(t) {
        var e = this, o = t.target.parent.getSiblingIndex(), a = this.type + o, n = {
            appid: this.data[o].appid,
            name: this.data[o].name,
            is_open_code: this.data[o].is_open_code,
            path: this.data[o].path,
            icon: this.data[o].icon,
            qr_code: this.data[o].qr_code
        };
        GA.PA.navigateToMiniProgram({
            pkgName: n.appid,
            appId: n.appid,
            path: n.path,
            success: function() {
                GA.saveRedirect(a, n.appid, n.path), e.loaddata(o);
            }
        });
    }, t.prototype.onBtn_closeClick = function() {
        var t = this, e = this.node.width;
        cc.tween(this.node).by(.3, {
            position: cc.v3(-e, 0)
        }).call(function() {
            t.btnClose.active = !1, t.node.parent.children[0].active = !1;
        }).start();
    }, a([ d([ cc.Button ]) ], t.prototype, "buttons", void 0), a([ d({
        visible: !0
    }) ], t.prototype, "type", void 0), a([ d({
        visible: !0
    }), d(cc.Node) ], t.prototype, "btnClose", void 0), a([ d({
        visible: !0
    }) ], t.prototype, "width", void 0), a([ l ], t);
}(cc.Component);

n.default = u;